<?php
require_once(dirname(__FILE__)."/../core/safeParam.php");
class module
{
  function Add($vars)
  {
    global $database;
    $action['name']        = $vars['name'];
    $action['code']        = $vars['code'];
    $action['description'] = $vars['description'];
    $action['type']        = $vars['type'];
    $action['discount']    = $vars['discount'];
    $action['minimum']     = $vars['minimum'];
    $action['rid']         = $vars['rid'];
    $database->insert_array('coupons', $action);
    header("Location: ../admin/index.php?edit=coupons&updated=1");
  }
  function Edit($vars)
  {
    global $database;
    $action['name']        = $vars['name'];
    $action['code']        = $vars['code'];
    $action['description'] = $vars['description'];
    $action['type']        = $vars['type'];
    $action['discount']    = $vars['discount'];
    $action['minimum']     = $vars['minimum'];
    $database->update_array('coupons', $action, "id = " . $vars['id'] . "");
    header("Location: ../admin/index.php?edit=coupons&updated=1");
  }
  function Delete($vars)
  {
    global $database;
    $database->delete('coupons', "id = " . $vars['id'] . "");
    header("Location: ../admin/index.php?edit=coupons&updated=1");
  }
}
?>
